<template>
	<view class="warp">
		<!-- #ifdef APP-PLUS -->
		<view class="title-contents">
			<view class="top-view status"></view>
		</view>
		<!-- #endif -->
		<view class="login-title">
			<view class="logo">
				<image src="/static/images/common/logo.png" mode=""></image>
			</view>
		</view>
		<!-- 密码登录 -->
		<view class="login-phone form-wapper">
			<view class="phone input-wapper">
				<view class="lside"><text class="iconfont icon-shouji"></text></view>
				<view class="mobile rside"><input placeholder-class="input-placeholder" type="number"
						placeholder="请输入手机号" v-model="username" /></view>
			</view>
			<view class="phone input-wapper">
				<view class="lside"><text class="iconfont icon-yanzhengma"></text></view>
				<view class="mobile rside"><input placeholder-class="input-placeholder" type="number"
						placeholder="请输入验证码" v-model="vercode" /></view>
				<view>
					<button type="default" @click="sendSms">获取验证码</button>
				</view>
			</view>
			<view class="code input-wapper">
				<view class="lside"><text class="iconfont icon-mima2"></text></view>
				<view class="rside"><input placeholder-class="input-placeholder" type="password" maxlength="12"
						placeholder="请输入密码(6-12位) " v-model="password" /></view>
			</view>
		</view>

		<button type="primary" class="login-btn" @click="reg">注册</button>
		<view class="reg-paw"><text class="active" @click="back">已有账号,返回登录</text></view>
	</view>
</template>
<script>
	import {regApi,sendSmsApi} from '@/api/user.js'
	export default {
		data() {
			return {
				username: '18568602726',
				password: '123456',
				vercode:''
			}
		},
		methods:{
			reg(){
				let {username,password,vercode} = this;
				regApi({username,password,vercode}).then(res=>{
					if(res.data.code==0){
						console.log(res.data)
						uni.navigateTo({
							url: '/pages/public/login?username='+ username,
						})
					}
				})
			},
			sendSms(){
				let mobile = this.username;
				let type = 'register';
				sendSmsApi({mobile,type}).then(res=>{
					console.log(res.data)
				})
			}
		}
	}
</script>
<style lang="scss">
	@import "login.scss"
</style>
